﻿<Window
	x:Class="ICSharpCode.PackageManagement.LicenseAcceptanceView"
	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
	xmlns:core="http://icsharpcode.net/sharpdevelop/core"
	xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
	xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
	xmlns:pm="clr-namespace:ICSharpCode.PackageManagement"
	xmlns:pmd="clr-namespace:ICSharpCode.PackageManagement.Design"
	mc:Ignorable="d"
	WindowStartupLocation="CenterOwner"
	Style="{x:Static core:GlobalStyles.DialogWindowStyle}"
	Title="License Agreements"
	Height="300"
	Width="480"
	MinHeight="300"
	MinWidth="300">
	
	<Window.Resources>
		<Style TargetType="Button" BasedOn="{x:Static core:GlobalStyles.ButtonStyle}"/>
		<BooleanToVisibilityConverter x:Key="BoolToVisibility"/>
		<pm:OpenHyperlinkCommand x:Key="OpenHyperlinkCommand"/>
	
		<DataTemplate x:Key="ListBoxItemTemplate">
			<Grid>
				<Grid.ColumnDefinitions>
					<ColumnDefinition Width="Auto"/>
					<ColumnDefinition />
				</Grid.ColumnDefinitions>
				<StackPanel Margin="4">
					<TextBlock 
						FontWeight="Bold"
						Text="{Binding Id}"/>
					<TextBlock>
						<Hyperlink
							Command="{StaticResource OpenHyperlinkCommand}"
							CommandParameter="{Binding Path=LicenseUrl}">
							<TextBlock Text="View License Terms"/>
						</Hyperlink>
					</TextBlock>
				</StackPanel>				
				<TextBlock 
					Grid.Column="1"
					Margin="4"
					TextTrimming="CharacterEllipsis"
					TextWrapping="Wrap"
					MaxHeight="40"
					Text="{Binding Summary}"/>
			</Grid>
		</DataTemplate>
	</Window.Resources>
	
	<Grid 
		d:DataContext="{d:DesignInstance pmd:DesignTimeLicenseAcceptanceViewModel, IsDesignTimeCreatable=True}">
		
		<Grid.RowDefinitions>
			<RowDefinition Height="Auto"/>
			<RowDefinition />
			<RowDefinition Height="Auto"/>
			<RowDefinition Height="Auto"/>
		</Grid.RowDefinitions>
	
		<StackPanel
			Margin="4, 2">
			<TextBlock 
				Visibility="{Binding Path=HasMultiplePackages, Converter={StaticResource BoolToVisibility}}"
				TextWrapping="Wrap"
				Text="The following packages require a click-to-accept license:"/>
			<TextBlock 
				Visibility="{Binding Path=HasOnePackage, Converter={StaticResource BoolToVisibility}}"
				TextWrapping="Wrap"
				Text="The following package requires a click-to-accept license:"/>
		</StackPanel>
		<Border 
			Grid.Row="1"
			BorderThickness="1"
			BorderBrush="{DynamicResource {x:Static SystemColors.ActiveBorderBrushKey}}">
			<ScrollViewer 
				VerticalScrollBarVisibility="Auto"
				HorizontalScrollBarVisibility="Disabled">
				<ItemsControl
					Background="{DynamicResource {x:Static SystemColors.WindowBrushKey}}"
					ItemTemplate="{StaticResource ListBoxItemTemplate}"
					ItemsSource="{Binding Path=Packages}"/>
			</ScrollViewer>
		</Border>
		<StackPanel
			Grid.Row="2"
			Margin="4">
			<TextBlock 
				Visibility="{Binding Path=HasMultiplePackages, Converter={StaticResource BoolToVisibility}}"
				TextWrapping="Wrap">
				By clicking "I Accept" you agree to the license terms for the packages listed above. 
				If you do not agree to the license terms click "I Decline".
			</TextBlock>
			<TextBlock 
				Visibility="{Binding Path=HasOnePackage, Converter={StaticResource BoolToVisibility}}"
				TextWrapping="Wrap">
				By clicking "I Accept" you agree to the license terms for the package listed above. 
				If you do not agree to the license terms click "I Decline".
			</TextBlock>
		</StackPanel>
		<StackPanel 
			Grid.Row="3"
			Margin="4"
			Orientation="Horizontal"
			HorizontalAlignment="Right">
			<Button 
				Content="I _Decline"
				IsCancel="True"/>
			<Button 
				Content="I _Accept" 
				Click="AcceptButtonClick"/>
		</StackPanel>
	</Grid>
</Window>